home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d22 / adjram41.arc / ADJRAM.DOC < prev    next >
Text File  |  1988-05-14  |  61KB  |  1,257 lines

  1.  
  2.  
  3.  
  4.                           ADJRAM -- Adjustable RAM Disk
  5.                                      
  6.                                 by Gary Cramblitt
  7.  
  8.                                    Version 4.1
  9.  
  10.         (c) Copyright 1986,1987,1988 by Gary Cramblitt.  All rights 
  11.             reserved.  Permission is granted to copy and use this 
  12.             software for non-commercial purposes only.  Permission is 
  13.             granted to distribute copies of this software provided no 
  14.             profit is obtained by doing so and that the entire package 
  15.             is distributed.  
  16.  
  17.             NOTICE:  This program is provided on an "as is" basis 
  18.             without warranty of any kind, expressed or implied, 
  19.             including but not limited to the implied warranties of 
  20.             mercantability and fitness for a particular purpose.  The 
  21.             entire risk as to quality and performance of this program is 
  22.             with you, the user.  Should the program prove defective, you 
  23.             assume the entire cost of all necessary repair, servicing, 
  24.             or correction.  In no event will the author be liable to you 
  25.             for any damages, including any lost profits, lost savings, 
  26.             or other incidental or consequential damages arising out of 
  27.             the use or inability to use this program.
  28.  
  29.  
  30.         This program, although copyrighted, may be freely copied and 
  31.         used, so long as it is not used for commercial purposes.  It is 
  32.         NOT shareware or user-supported software.  You are not expected 
  33.         to make a donation to the author for using this program.  Enjoy 
  34.         -- and try to do the same for others some day.  
  35.  
  36.         If you distribute copies of this software to others, you are 
  37.         REQUIRED to distribute the ENTIRE package consisting of the 
  38.         following files: 
  39.  
  40.                 AMDISK.DVD
  41.                 ADJRAM.EXE
  42.                 ADJRAMEM.EXE
  43.                 ADJRAM.DOC
  44.                 AMDISK.ASM
  45.                 ADJRAM.C
  46.  
  47.         If you leave any of the above files out, you will be in 
  48.         violation of copyright.  You may charge a distribution fee for 
  49.         ADJRAM so long as the recipient is not charged more than a total 
  50.         of $6.00 (including tax and postage) to receive ADJRAM.  If you 
  51.         charge more than that, you are in violation of copyright.  
  52.  
  53.         
  54.         READ THIS DOCUMENTATION
  55.         -----------------------
  56.         Using this program without first reading all of this document 
  57.         can be hazardous to your data.  While the program has been 
  58.         reasonably tested for defects, the nature of its algorithm is 
  59.         such that under certain conditions it will fail and this could 
  60.         in turn cause loss of valuable data.  The section on 
  61.         Compatibility and Memory Usage and the section on Errors are 
  62.         particularly important.  
  63.  
  64.  
  65.         What Is ADJRAM?
  66.         ---------------
  67.         ADJRAM is a RAM disk program.  Sometimes, RAM disks are called 
  68.         "virtual disks" like the VDISK supplied with PC-DOS.  Sometimes 
  69.         they are called "memory disks" like MEMBRAIN.  Whatever you call 
  70.         it, a RAM disk is a program that makes a section of the Random 
  71.         Access Memory (RAM) of your computer look like a floppy disk 
  72.         drive to DOS.  The advantage is that RAM is many hundreds of 
  73.         times faster than a floppy disk -- even faster than a hard disk.  
  74.  
  75.         Why use ADJRAM, when you already have VDISK or MEMBRAIN or some 
  76.         other RAM disk?  Because ADJRAM allows you to vary the size of 
  77.         the RAM disk without rebooting, and without loss of existing 
  78.         data stored in the RAM disk.  For example, you can start out 
  79.         with 64K of your memory allocated for the RAM disk, expand it 
  80.         later to 320K, copy a document file of 60K to the RAM disk, and 
  81.         still later reduce the RAM disk capacity back down to 128K -- 
  82.         without losing your document file.
  83.  
  84.         ADJRAM is ideal for those who do not have a hard disk.  It also 
  85.         supports LOTUS/INTEL/Microsoft Expanded Memory and Reserved 
  86.         Memory (explained later).  It does not support Extended Memory.
  87.  
  88.         Requirements
  89.         ------------
  90.         ADJRAM is designed to run under MS-DOS version 2 or greater.  It 
  91.         has been tested on the following machines:
  92.  
  93.              1.  Zenith Z100 under MS-DOS version 2.21
  94.              2.  Zenith Z171 (an IBM PC compatible) under MS-DOS version 
  95.                  2.11
  96.              3.  KayPro 16 also under MS-DOS 2.11
  97.              4.  Tandy 1000 under MS-DOS 2.11
  98.              5.  Sperry Personal Computer with 2 Mbyte JRAM 3 card under 
  99.                  MS-DOS 3.1 
  100.              6.  EPSON Equity I under MS-DOS 2.11 
  101.              7.  COMPAQ DeskPro (80186) under IBM DOS 3.10
  102.              8.  IBM PC Portable.  
  103.              9.  Sharp PC-5000.
  104.              10. Zenith Z160 under DOS 3.1.
  105.              11. XEROX 6060 under MS-DOS 3.1.
  106.              12. Epson Equity I under MS-DOS 2.11.
  107.  
  108.         It requires approximately 14K bytes of disk space.  Memory usage 
  109.         is, of course, a function of the RAM disk's size, but it 
  110.         requires a minimum of 50K free RAM.  
  111.  
  112.  
  113.         Installation
  114.         ------------
  115.         Note: If you have a computer with LOTUS/INTEL/Microsoft Expanded 
  116.               Memory and you want ADJRAM to use the Expanded Memory, 
  117.               please read the section below entitled "Expanded Memory 
  118.               Support" before you install ADJRAM.  
  119.  
  120.         Copy the following files to your boot disk: 
  121.  
  122.              AMDISK.DVD
  123.              ADJRAM.EXE
  124.  
  125.         Edit your CONFIG.SYS file and place the following line in it:
  126.  
  127.              device = amdisk.dvd
  128.  
  129.         Reboot your computer.  If all goes well, you should see the 
  130.         following message appear near the beginning of your boot 
  131.         sequence:
  132.  
  133.              AMDISK v4.1 (c) Copyright 1986,1987,1988 by Gary Cramblitt
  134.                -- Initialized as disk C:
  135.  
  136.         The disk drive letter will vary according to your system 
  137.         configuration.  Remember that drive letter, since it is that 
  138.         disk which is your RAM disk.  
  139.  
  140.         If you use any memory resident programs, such as Sidekick (a 
  141.         trademark of Borland International), load them before attempting 
  142.         to change the size of the RAM disk (as explained in the next 
  143.         section).  
  144.         
  145.         MS-DOS 3.x users may need to add a LASTDRIVE= clause to their 
  146.         CONFIG.SYS file.  Consult your DOS manual.
  147.  
  148.                                                         
  149.         Using the RAM Disk
  150.         ------------------
  151.         The RAM disk is used just like any floppy disk drive.  You can 
  152.         copy files to or from it, create directories on it, erase files, 
  153.         etc.  You may NOT do the following things with the RAM disk:
  154.         
  155.              1.  You may not FORMAT the RAM disk.
  156.              2.  You may not DISKCOPY from or to the RAM disk.
  157.              3.  You may not run SYS against the RAM disk.
  158.              4.  You may not boot from the RAM disk.
  159.              5.  You may not use any program on the RAM disk that 
  160.                  accesses the disk controller circuitry directly.  Some 
  161.                  anti-copy protection programs fall into this category.
  162.              6.  You may not use any program that depends upon IBM
  163.                  standard disk media codes.
  164.  
  165.         Restrictions 1 through 5 are generally true of any RAM disk.  
  166.         Restriction 6 is unique to the Adjustable RAM Disk because it 
  167.         uses a non-standard media descriptor byte.  This shouldn't cause 
  168.         great hardship though.  
  169.  
  170.         Also, keep in mind that anything stored in the RAM disk can 
  171.         potentially be lost.  For example, should your power fail and 
  172.         you don't have an Uninterruptible Power Source (UPS), then 
  173.         everything in the RAM disk will be lost.  If you reboot (by 
  174.         pressing CTRL-ALT-DEL for example), the contents of the RAM disk 
  175.         are lost.  It is a good idea to periodically copy important 
  176.         files to a more permanent medium, such as floppy disk.  
  177.  
  178.  
  179.         Using ADJRAM
  180.         ------------
  181.         The RAM disk defaults to a size of 64K bytes when you first boot 
  182.         the system.  The ADJRAM program is used to change this size.  
  183.         For example, to increase the size of the RAM disk by 64K bytes, 
  184.         enter the following command to the DOS prompt: 
  185.  
  186.              ADJRAM C: +64
  187.  
  188.         The spaces after "ADJRAM" and after "C:" are required.  The 
  189.         drive letter (C:) will vary according to your system's 
  190.         configuration.  Use whatever letter was displayed by AMDISK when 
  191.         you booted the system.
  192.         
  193.         In case you missed it, I'll repeat:  The spaces after "ADJRAM" 
  194.         and after the drive are required.
  195.  
  196.         When ADJRAM is run, you should see something like this displayed 
  197.         on your screen: 
  198.  
  199.              Adjustable RAM Disk v4.1 (c) Copyright 1986,1987 by Gary Cramblitt
  200.              Drive C:   Total Size: 64K        Free Space: 61K
  201.                  Max Possible Size: 618K    Max Expansion: 554K
  202.                         Final Size: 128K    Amount Change: 64K
  203.              ADJRAM Exiting (code 0)
  204.  
  205.         The drive letter displayed will vary, as I've already explained.  
  206.  
  207.         ADJRAM always increments its size in 32K junks, called "memory 
  208.         blocks".  The change you specify is always rounded up to the 
  209.         next closest multiple of 32.  In the example above, two new 32K 
  210.         memory blocks are created for the additional 64K of space.
  211.  
  212.         To see where the memory blocks are located and what their size 
  213.         is, use the following command:
  214.  
  215.              ADJRAM C: /t
  216.  
  217.         The "/t" option tells ADJRAM to display the Memory Block Table.
  218.  
  219.         You must have sufficient free memory to allocate the additional 
  220.         size.  ADJRAM will automatically determine the maximum size 
  221.         possible and display it for you.  If you request too large a 
  222.         size, ADJRAM will round down the request to the nearest 32K 
  223.         increment.
  224.  
  225.         You can also shrink the RAM disk.  For example, the following 
  226.         command would decrease the size of the RAM disk by 32K: 
  227.  
  228.              ADJRAM C: -32
  229.  
  230.         You must have sufficient free space in the RAM disk in order to 
  231.         shrink it.  To find out how much free space you have in the RAM 
  232.         disk, enter the following command:
  233.  
  234.              ADJRAM C:
  235.  
  236.         Notice how there is no size parameter.  The program will display 
  237.         the current size and free space of the RAM disk.  If you have 
  238.         insufficient space, you must erase enough files to get 
  239.         sufficient space.  Then enter your ADJRAM command again.  
  240.  
  241.         You can not shrink the RAM disk to less than 64K.  (See the 
  242.         section later entitled "Specifying an Initial Size" for a way 
  243.         around this restriction.)
  244.  
  245.         Instead of giving the size of the RAM disk as a plus or minus 
  246.         figure, you can specify the desired size of the RAM disk like 
  247.         this:
  248.  
  249.              ADJRAM C: 320
  250.  
  251.         This command will set the RAM disk to 320K.  If it is currently 
  252.         larger than 320K, it will shrink it down to 320K (provided there 
  253.         is sufficient free space to do so).  If it is currently smaller 
  254.         than 320K, it will expand the size to 320K by allocating new 
  255.         memory blocks.  Remember that ADJRAM will round the figure you 
  256.         specify to the next higher multiple of 32.  
  257.  
  258.         If you want to adjust the size of the RAM disk so that it has 
  259.         200K of free space, enter a command like this: 
  260.  
  261.              ADJRAM C: f200
  262.  
  263.         Notice the letter "f" in front of the size.  This command will 
  264.         expand or shrink the RAM disk so as to ensure there is about 
  265.         200K of free space IN THE RAM DISK.  
  266.  
  267.         If you want to ensure there is AT LEAST 128K of free space in 
  268.         the RAM disk, enter a command like this:
  269.  
  270.              ADJRAM C: m128
  271.  
  272.         Notice the letter "m" in front of the size.  This command will 
  273.         never shrink the RAM disk, but it may expand it to make sure 
  274.         there is a minimum of 128K of free space.  This form of the 
  275.         command is particularly handy within batch files to make sure 
  276.         the RAM disk is large enough to hold a file before it is copied 
  277.         into the RAM disk.
  278.  
  279.  
  280.         Online Help
  281.         -----------
  282.         If you can't remember the format for all these commands, fear 
  283.         not.  Simply enter 
  284.  
  285.              ADJRAM
  286.  
  287.         and it will display a help message showing the formats described 
  288.         above.
  289.  
  290.  
  291.         Hint for Floppy Disk Systems
  292.         ----------------------------
  293.         If you do not have a hard disk, soon after booting your 
  294.         computer, copy file ADJRAM.EXE to the RAM disk, for example:
  295.  
  296.              COPY A:ADJRAM.EXE C:
  297.  
  298.         You can then modify the size of the RAM disk at any time 
  299.         thereafter without needing the boot disk.  Just put the RAM disk 
  300.         drive letter in front of any ADJRAM commands.  For example:
  301.  
  302.              C:ADJRAM C: -32
  303.  
  304.         You can put the COPY command into your AUTOEXEC.BAT file.
  305.  
  306.  
  307.         Specifying an Initial Size
  308.         --------------------------
  309.         By default, AMDISK sizes itself to 64K when it is initially 
  310.         loaded at boot time.  If you wish, you can alter this initial 
  311.         size by placing a "MINSIZE=" clause in CONFIG.SYS.  For example, 
  312.         to set the initial size to 32K, you would put the following line 
  313.         into CONFIG.SYS: 
  314.  
  315.              DEVICE = AMDISK.DVD MINSIZE=32
  316.  
  317.         The size may be a minimum of 15 and a maximum of 512.  Large 
  318.         initial sizes are definitely not recommended however, because 
  319.         you can never shrink the RAM disk to less than its initial size.  
  320.         For example, if you put a "MINSIZE=256" into CONFIG.SYS, you can 
  321.         never make the RAM disk any smaller than 256K.  
  322.  
  323.         ADJRAM always expands and shrinks the RAM disk in 32K 
  324.         increments.  If you specify an initial size that is not an even 
  325.         multiple of 32, then ADJRAM will round your sizes to some 
  326.         strange numbers.  For example, if you specify "MINSIZE=15" in 
  327.         CONFIG.SYS, and then give the following command: 
  328.  
  329.              ADJRAM C: 128
  330.  
  331.         ADJRAM will actually size the RAM disk to 143K (15 + 4*32).  For 
  332.         this reason, I recommend that you always specify an even 
  333.         multiple of 32 in your "MINSIZE=" clause.
  334.  
  335.  
  336.         Expanded Memory Support
  337.         -----------------------
  338.         ADJRAM provides full support for LOTUS/INTEL/Microsoft Expanded 
  339.         Memory (EMS version 3.2 compatible).  
  340.  
  341.         If you have a computer with LOTUS/INTEL/Microsoft Expanded 
  342.         Memory and you want ADJRAM to use that memory, the installation 
  343.         is a little different.  Instead of copying ADJRAM.EXE to your 
  344.         boot disk, copy file ADJRAMEM.EXE and then rename it to 
  345.         ADJRAM.EXE.
  346.         
  347.         Depending upon how much expanded memory you have and how large 
  348.         you expect to make the RAM disk, you may also need to add a 
  349.         "CLUSTER=" clause to CONFIG.SYS.  For example, if you have 8MB 
  350.         of expanded memory (the maximum possible) your CONFIG.SYS file 
  351.         would have the following statement:
  352.  
  353.              DEVICE = AMDISK.DVD CLUSTER=4
  354.  
  355.         The following table shows the cluster sizes you should use for 
  356.         corresponding maximum RAM disk sizes:
  357.  
  358.              Maximum
  359.              RAM Disk
  360.              Size (K)         CLUSTER=
  361.              --------         --------
  362.               2043               1 (default)
  363.               4083               2
  364.               8166               4
  365.              16332               8
  366.  
  367.         The rest of the installation is the same as for the non-expanded 
  368.         memory version.
  369.  
  370.         If you want ADJRAM to create new memory blocks in 
  371.         LOTUS/INTEL/Microsoft Expanded Memory, add a "/E" option, like 
  372.         this: 
  373.  
  374.              ADJRAM C: +256 /E
  375.  
  376.         This command will expand the RAM disk by 256K.  The additional 
  377.         256K memory block will be created within LOTUS/INTEL/Microsoft 
  378.         Expanded Memory.  If ADJRAM ends up shrinking the RAM disk, the 
  379.         "/E" switch is meaningless.  Remember that ADJRAM will always 
  380.         shrink the RAM disk by freeing memory blocks in reverse of the 
  381.         order in which they were created.  
  382.  
  383.         The version of ADJRAM that supports Expanded Memory can not be 
  384.         used in conjunction with the version that does not support it.  
  385.         Don't get them mixed up.  Use ADJRAMEM.EXE (renamed to 
  386.         ADJRAM.EXE) or use ADJRAM.EXE -- but not both.
  387.         
  388.         Instead of allocating memory blocks in 32K increments, ADJRAM 
  389.         allocates expanded memory blocks in 256K increments.  
  390.         Consequently, it will shrink in 256K increments as well.  If you 
  391.         mix conventional memory blocks with expanded memory blocks, the 
  392.         shrinkage boundaries will vary.  Just remember that ADJRAM 
  393.         always deallocates memory blocks in reverse of the order they 
  394.         were created, and that it must always deallocate entire memory 
  395.         blocks.  Playing with the combinations and using the "/t" option 
  396.         will help you to understand what is going on.  
  397.  
  398.         One EMM handle is used for each new 256K memory block.  Hence, a 
  399.         2MB expanded memory RAM disk will use 8 handles.  
  400.  
  401.         The Expanded Memory support in this version of ADJRAM was coded 
  402.         based on information from the book "Advanced MS-DOS" by Ray 
  403.         Duncan.  The code was tested on a Sperry PC with a 2 Mbyte JRAM 
  404.         3 memory board installed (JBOOT and JPAGER loaded).  I don't own 
  405.         a computer with Expanded Memory, so this part of the program is 
  406.         the least tested.  Please be cautious until you've had time to 
  407.         thoroughly check out the program -- and let me know if you 
  408.         encounter difficulty.  
  409.  
  410.  
  411.         Using Reserved Memory
  412.         ---------------------
  413.         Beginning with verson 4.0, ADJRAM now supports Reserved 
  414.         Memory.  This capability should only be used by those who 
  415.         understand 8086 addressing and have sufficient technical 
  416.         background.  Others should skip this section entirely.  
  417.  
  418.         Support for Reserved Memory was added because many computers 
  419.         have banks of memory not otherwise usable.  For example, in the 
  420.         IBM Portable, banks A, C, D, and E are not normally used for 
  421.         anything.  Some portable clones have a megabyte of memory, but 
  422.         only 640K is usable.
  423.  
  424.         To understand what Reserved Memory is, here are a few 
  425.         definitions: 
  426.  
  427.             1.  CONVENTIONAL Memory is directly addressable by the 8088 
  428.                 or 8086 CPU and is controlled by DOS.  On the IBM PC, it 
  429.                 is the memory from 0 to 640K.
  430.         
  431.             2.  RESERVED Memory is also directly addressable by the 8088 
  432.                 or 8086 CPU but it is not controlled by DOS.  On the IBM 
  433.                 PC, it would be memory from 640K to 1MB.  This memory is 
  434.                 normally reserved for use by the BIOS.  For example, the 
  435.                 memory from B0000 to BFFFF is reserved for monochrome 
  436.                 and graphics video memory.  
  437.         
  438.             3.  EXTENDED Memory is only found in AT class machines.  It 
  439.                 is memory above 1MB that is directly addressable by the 
  440.                 80286 (protected mode) or 80386 CPUs.  Extended Memory 
  441.                 is not currently supported by ADJRAM.  Some PC and XT 
  442.                 class machines have "extended" memory boards in them 
  443.                 that don't meet the definition of Extended Memory I've 
  444.                 given here.  Such memory must be "bank switched" or 
  445.                 "paged" into the 8088 or 8086's address area (0 to 1MB).  
  446.                 The JRAM 3 memory card is one such type of memory.  If 
  447.                 the vendor sells an Expanded Memory Manager (EMM) for 
  448.                 the board, then that memory can be used by ADJRAM.  
  449.         
  450.             4.  EXPANDED Memory adheres to the LOTUS/INTEL/Microsoft 
  451.                 Expanded Memory Specification (v3.2).  Note that 
  452.                 Expanded Memory is implemented through the Expanded 
  453.                 Memory Manager (EMM), and may actually reside anywhere.  
  454.                 For example, with appropriate software, it is possible 
  455.                 to convert Extended Memory into Expanded Memory.  
  456.  
  457.         Now back to Reserved Memory.  IBM reserved the memory from A0000 
  458.         to FFFFF.  For example, they reserved memory from A0000 to AFFFF 
  459.         for the Enhanced Graphics Adaptor (EGA).  If your computer 
  460.         doesn't have an EGA, you may be able to use those addresses for 
  461.         ADJRAM.  
  462.         
  463.         Suppose you wanted to put 64K at address A0000 to AFFFF.  To do 
  464.         this, you would have to install a memory board with 64K 
  465.         "jumpered" or "strapped" so that its memory resides at addresses 
  466.         A0000 to AFFFF.  The memory must be directly addressable by the 
  467.         CPU at addresses A0000 to AFFFF.  No "bank switching", "paging", 
  468.         or "enabling" is allowed.  
  469.  
  470.         Now specify a command of the following form to expand into this 
  471.         Reserved Memory:
  472.  
  473.              ADJRAM C: r:a000:64 /T
  474.  
  475.         You must use the Expanded Memory version of ADJRAM 
  476.         (ADJRAMEM.EXE renamed to ADJRAM.EXE).  The format must be 
  477.         exactly as shown, i.e., an "R" followed by a colon, followed by 
  478.         a four digit hexadecimal paragraph address, followed by a colon, 
  479.         followed by a decimal size.  (You get a paragraph address by 
  480.         dropping the last hexadecimal digit from a 5 hex digit address).  
  481.         Notice that this "R" option replaces the normal "size" parameter 
  482.         in an ADJRAM command.  The maximum size permitted is 64.  The 
  483.         hexadecimal address must be in the range A000 to FFFF and it 
  484.         must point to valid reserved memory.
  485.  
  486.         ADJRAM doesn't do ANY error checking of this command, so use 
  487.         with extreme caution.  The "/T" option is used so that you can 
  488.         verify that the memory block was properly added to the Memory 
  489.         Block Table.  In this example, a single 64K block is added 
  490.         beginning at paragraph A000.
  491.  
  492.         You may have additional Reserved Memory, or you may wish to 
  493.         allocate the memory in smaller blocks so that shrinkage can be 
  494.         fine-tuned.  To do that, just specify additional ADJRAM commands 
  495.         -- one for each new block.  For example, to divide the 64K block 
  496.         starting at A000 into four blocks of 16K, give the following 
  497.         commands: 
  498.  
  499.              ADJRAM C: r:a000:16
  500.              ADJRAM C: r:a400:16
  501.              ADJRAM C: r:a800:16
  502.              ADJRAM c: r:AC00:16 /t
  503.  
  504.         You will normally want to specify the Reserved Memory commands 
  505.         in your AUTOEXEC.BAT.
  506.  
  507.         If you find this capability useful, please let me know.
  508.  
  509.  
  510.        
  511.         Error Messages
  512.         --------------
  513.         In general, error messages are prefaced by either the phrase 
  514.         "Error --" or the phrase "Warning --".  Warning messages are not 
  515.         fatal.  The program will automatically adjust for them.  For 
  516.         example, if you attempt to make the RAM disk larger than 
  517.         available free memory, ADJRAM will automatically make it as 
  518.         large as possible.
  519.         
  520.         Most errors will stop the program immediately.  However, once 
  521.         the "Final Size" line appears, ADJRAM has begun to reorganize 
  522.         the RAM disk.  If it gets an error during this time, it will 
  523.         attempt to keep going; and when it does exit, the following 
  524.         message will appear: 
  525.  
  526.              *** Sorry, RAM disk has been corrupted.  Recommend that you
  527.                  check your files, save them if possible, and reboot.
  528.  
  529.         If this message appears, you should immediately do just what it 
  530.         says.  If you don't need any of the data in the RAM disk, you 
  531.         should reboot immediately.  If you do need the data, first check 
  532.         the files to see if they are OK.  You can check ASCII text files 
  533.         by TYPEing them.  If the files you need appear to be OK, then 
  534.         copy them to a more permanent medium, such as floppy disk, and 
  535.         reboot.
  536.  
  537.         Whenever ADJRAM exits, a message such as the following appears:
  538.  
  539.              ADJRAM exiting (code 0)
  540.  
  541.         The code number in parenthesis indicates the ERRORLEVEL code 
  542.         being passed to DOS.  A code of 0 means "no error".  These codes 
  543.         can be tested by DOS IF statements in batch commands.  More on 
  544.         this later.
  545.         
  546.         There are also a large number of possible errors that MS-DOS 
  547.         will display while you're working with the RAM disk.  Consult 
  548.         your DOS manual.  One message I'd like to point out.  If you see 
  549.  
  550.              Bad File Allocation Table
  551.  
  552.         (or something similar) the RAM disk is probably corrupted.  
  553.         Carefully check your files.  If they are OK, copy them to a more 
  554.         permanent medium, such as floppy disk, then reboot.  
  555.  
  556.         Here is a list of possible error messages you might see 
  557.         displayed by the ADJRAM.EXE program and their probable cause 
  558.         (the numbers in parenthesis are the ERRORLEVEL codes passed to 
  559.         DOS).  First time users will want to skip the rest of this 
  560.         section.  Keep this .DOC file handy though, in case you need 
  561.         help understanding an error message: 
  562.  
  563.              Error -- could not read boot sector.  Error code xx (15)
  564.  
  565.         The program could not read the boot sector (logical sector 0) of 
  566.         the RAM disk.  An invalid drive letter was specified or the RAM 
  567.         disk has become corrupted.  In the latter case, reboot is 
  568.         recommended.  
  569.  
  570.              Error -- that drive is not the adjustable RAM disk or 
  571.         invalid version of AMDISK for this version of ADJRAM (15) 
  572.  
  573.         An invalid drive letter was specified.  Use the letter that was 
  574.         reported by AMDISK when you booted the computer.  Make sure you 
  575.         used the correct command syntax.  A space must follow "ADJRAM".  
  576.         It could also occur if you've mixed version 4.0 of ADJRAM with 
  577.         an older version of AMDISK.  In this case, you need to update 
  578.         AMDISK.DVD.
  579.  
  580.              Error -- could not free environment block.  Error code xx 
  581.         (10)
  582.  
  583.         This error would indicate you have an incompatible version of 
  584.         MS-DOS.  The error codes are those returned by DOS function 49H.
  585.  
  586.              Error -- Bad reserved memory parameter (1)
  587.  
  588.         You gave an "R" option but in the wrong format.  Format is
  589.         R:hhhh:dd.  For example, a reserved memory block starting at 
  590.         paragraph D000 and 32K long would be specified as r:d000:32
  591.         A common error is to forget one of the colons.  Also, the 
  592.         starting address is exactly 4 hexadecimal digits long.  Correct 
  593.         and try again.  
  594.         
  595.              Error -- Unable to locate reserved memory block from
  596.         xxxx:xxxx to xxxx:xxxx (8)
  597.  
  598.         You gave an "R" option but specified memory that ADJRAM could 
  599.         not find.  For example, a reserved memory block starting at 
  600.         paragraph D000 and 32K long would be specified as r:d000:32.  A 
  601.         common error is to overlap with read-only memory or to overlap 
  602.         with video memory.  ADJRAM tests the specified block by writing 
  603.         a test byte at the beginning and end of the block.  If it can 
  604.         not read the same byte back, you get this error.  Check your 
  605.         technical documentation and try again.
  606.         
  607.              Error -- Invalid drive letter or RAM disk is not loaded 
  608.         (15)
  609.  
  610.         ADJRAM reports this error if DOS returns an error code from 
  611.         function 36H (get free disk space).  Check your drive letter and 
  612.         command syntax.
  613.  
  614.              Warning - Insufficient free space in disk to shrink that much 
  615.         (8)
  616.  
  617.         You do not have enough free space in the RAM disk to shrink it 
  618.         by the requested amount.  ADJRAM will attempt to shrink the disk 
  619.         as much as possible.  First erase some files from the RAM disk, 
  620.         then reenter you command.  
  621.  
  622.              Warning -- Rounding your requested change of xxK to xxK
  623.  
  624.         ADJRAM is showing you how it has adjusted your expansion or 
  625.         shrinkage request to fall within allowable boundaries.  Does not 
  626.         alter the ERRORLEVEL code.
  627.  
  628.              Error -- could not modify memory block size.  Error code xx 
  629.         (8)
  630.  
  631.         This error occurs when expanding the RAM disk.  The program 
  632.         received an error code from DOS function 4AH (modify memory 
  633.         allocation) on the first new 32K memory block to be created.  It 
  634.         could be caused by corrupted memory allocation, possibly 
  635.         caused by incompatibility with other memory resident programs.  
  636.         Reboot is recommended.
  637.  
  638.               Error -- could not allocate new memory block.  Error code 
  639.         xx (8) 
  640.  
  641.         This error is similar to the one above except that it occurs on 
  642.         the second and subsequent new 32K memory blocks when the program 
  643.         invokes DOS function 48H (allocate memory).  Since the program 
  644.         supposedly made sure there was sufficient memory before 
  645.         attempting the expansion, getting this message would indicate an 
  646.         internal bug.
  647.  
  648.              Error -- could not allocate new memory block from EMM.  
  649.         Error code xx (8) 
  650.  
  651.         This error is similar to the one above except that it occurs in 
  652.         conjunction with creating new 256K memory blocks in 
  653.         LOTUS/INTEL/Microsoft Expanded Memory.  The program will attempt 
  654.         to keep going without expanding the disk any further.  This 
  655.         condition is not well tested though, so to be safe, reboot is 
  656.         recommended.  
  657.  
  658.              Error -- could not write boot sector back.  Code: xx (15)
  659.  
  660.         This is most likely an internal program error.  The program got 
  661.         an error code from DOS interrupt 26H (write absolute disk 
  662.         sector).  Reboot is required.  
  663.  
  664.              Error -- could not free allocated memory block #xx.  Error 
  665.         code xx 
  666.         
  667.         This error occurs when shrinking the RAM disk.  The program got 
  668.         an error code from DOS function 49H (release memory).  Could be 
  669.         caused by an internal program bug, incompatible memory resident 
  670.         program, or incompatible version of DOS.  The program attempts 
  671.         to exit gracefully so that you can recover data files from the 
  672.         RAM disk, but you should reboot as soon as possible.  
  673.  
  674.              Error -- could not free EM pages for memory block #xx.  
  675.         Error code xx 
  676.         
  677.         This error occurs when shrinking the RAM disk.  The program got 
  678.         an error condition from the LOTUS/INTEL/Microsoft Expanded 
  679.         Memory Manager.  Could be caused by an internal program bug, 
  680.         incompatible memory resident program, or incompatible version of 
  681.         DOS.  The program attempts to exit gracefully so that you can 
  682.         recover data files from the RAM disk, but you should reboot as 
  683.         soon as possible.  
  684.  
  685.              Error -- Insufficient stack space to pack subdirectory 
  686.         xxxxxxxx.  Too many subdirectories.  Shrink abandoned. (4)
  687.  
  688.         This error occurs when shrinking the RAM disk.  The DeSmet C 
  689.         stack space was insufficient to handle the depth of 
  690.         subdirectories you have on your RAM disk.  The program attempts 
  691.         to exit gracefully without completing the shrink.  This 
  692.         condition has not been fully tested, so caution, your files may 
  693.         have been corrupted.  In the future, don't use so many 
  694.         subdirectories.  
  695.  
  696.              Error -- Error while packing file xxxxxxxx
  697.  
  698.         This error occurs when shrinking the RAM disk.  It will usually 
  699.         be displayed after the previous message.  It may also appear if 
  700.         an internal error occurs, such as inability to read or write 
  701.         sectors of the file.  The program attempts to exit gracefully 
  702.         without completing the shrink.  
  703.  
  704.              Error -- Expanded Memory Manager is not avaiable.  Error 
  705.         code: xx (15) 
  706.  
  707.         You specified the "/E" option, but the LOTUS/INTEL/Microsoft 
  708.         Expanded Memory Manager (EMM) is not loaded.  Load the EMM and 
  709.         try again.
  710.  
  711.              Error -- Expanded Memory Manager could not report page 
  712.         frame.  Error code: xx (8)
  713.  
  714.         The EMM was detected by ADJRAM, but the EMM reported an error 
  715.         when ADJRAM asked for the page frame segment address (EMM 
  716.         function 41H).  This could be caused by a corrupted EMM, or an 
  717.         incompatible version of the EMM (ADJRAM requires version 3.2 
  718.         compatibility), or possibly ADJRAM encountered a "busy" 
  719.         condition from the EMM.  Try again.  If it still fails, you'll 
  720.         have to stick with normal memory.  
  721.  
  722.         There are two other conditions which do not display an error 
  723.         message.  In these cases, the program simply displays the help 
  724.         message and exits:
  725.  
  726.              1.  Invalid drive letter specified.  Must be in range A 
  727.                  through L. (15)
  728.  
  729.              2.  Invalid size specified.  For Conventional Memory, must 
  730.                  be in range 64 to 2016.  (1).  
  731.  
  732.         
  733.  
  734.         Using ADJRAM in Batch Files
  735.         ---------------------------
  736.         If an error occurs while running ADJRAM, it will return a DOS 
  737.         error code when it exits back to DOS.  The error codes returned 
  738.         are shown in parenthesis in the error message section above.  
  739.         They are also displayed in the "ADJRAM exiting" message.  These 
  740.         error codes can be used in a batch file via the DOS IF 
  741.         command.  See your DOS manual for details.  For example, I use 
  742.         the following batch command file to load PROCOMM into the RAM 
  743.         disk.  Procomm's files require about 175K of space: 
  744.         
  745.              c:adjram c: m175
  746.              if not error level 0 goto noram
  747.              copy a:procomm.* c:
  748.              c:
  749.              rem Type PROCOMM /B
  750.              goto xit
  751.              noram:
  752.              rem Not enough room in ram disk.
  753.              xit:
  754.                
  755.         Some versions of MS-DOS (Z100 v2.21 for example) have a command 
  756.         which will cause error codes to be displayed.  It is: 
  757.  
  758.               XYZZY ON
  759.  
  760.  
  761.         Compatibility and Memory Usage
  762.         ------------------------------
  763.         The Adjustable RAM Disk falls into a class of programs known as 
  764.         Memory Resident programs.  Sidekick is one such program.  These 
  765.         programs are sometimes incompatible with one another.  It is 
  766.         impossible for me to test the Adjustable RAM disk in combination 
  767.         with every available memory resident program, so I'll apologize 
  768.         ahead of time -- some incompatibilities are almost certain to 
  769.         crop up.  
  770.  
  771.         Sometimes, changing the order inwhich the programs are loaded 
  772.         makes a difference.
  773.  
  774.         Generally, you should load all of your memory resident programs 
  775.         BEFORE you run ADJRAM.  (I know, every memory resident program 
  776.         wants to be loaded last, but please bear with me!)  You should 
  777.         do this to make the most efficient use of memory.  Here's why.  
  778.         When you expand the RAM disk, ADJRAM allocates 32K memory blocks 
  779.         using the DOS memory allocation functions.  Once that is done, 
  780.         any subsequent memory resident programs you load will generally 
  781.         get loaded above these new memory blocks.  When you later shrink 
  782.         the RAM disk, ADJRAM deallocates the memory blocks.  If you have 
  783.         loaded a memory resident program after expanding the RAM disk 
  784.         with ADJRAM, then "holes" in the memory allocation will be 
  785.         created when you later shrink the RAM disk.  These holes will 
  786.         generally not be usable for transient programs until you unload 
  787.         the memory resident program (which might not even have that 
  788.         capability).  
  789.         
  790.         To help you understand what is happening, consider a system with 
  791.         the following CONFIG.SYS file
  792.  
  793.              device = amdisk.dvd
  794.              device = ansi.sys
  795.         
  796.         and the following (incorrect) AUTOEXEC.BAT:
  797.  
  798.              copy adjram.exe c:
  799.              c:adjram c: +64
  800.              sk
  801.  
  802.         Notice that Sidekick is incorrectly loaded AFTER expanding the 
  803.         RAM disk.  At the completion of the boot, the following memory 
  804.         layout exists: 
  805.  
  806.              +--------------------------------+ 640K
  807.              |                                |
  808.              |   Transient Program Area       |
  809.              |                                |
  810.              +--------------------------------+
  811.              |           Sidekick             |
  812.              +--------------------------------+
  813.              |   Block #2 of RAM Disk (32K)   |
  814.              +--------------------------------+
  815.              |   Block #1 of RAM Disk (32K)   |
  816.              +--------------------------------+
  817.              |           ANSI.SYS             |
  818.              +--------------------------------+
  819.              |   Block #0 of RAM disk (64K)   |
  820.              |                                |
  821.              +--------------------------------+
  822.              |          AMDISK.DVD            |
  823.              +--------------------------------+
  824.              |         BIOS and DOS           |
  825.              +--------------------------------+ 0K
  826.  
  827.         If the user were to shrink the RAM disk now, say with the 
  828.         following command 
  829.  
  830.              C:ADJRAM C: -32
  831.  
  832.         then the memory layout would change to this:
  833.  
  834.              +--------------------------------+ 640K
  835.              |                                |
  836.              |   Transient Program Area       |
  837.              |                                |
  838.              +--------------------------------+
  839.              |           Sidekick             |
  840.              +--------------------------------+
  841.              |     32K unusable "hole"        |
  842.              +--------------------------------+
  843.              |   Block #1 of RAM Disk (32K)   |
  844.              +--------------------------------+
  845.              |           ANSI.SYS             |
  846.              +--------------------------------+
  847.              |   Block #0 of RAM disk (64K)   |
  848.              |                                |
  849.              +--------------------------------+
  850.              |          AMDISK.DVD            |
  851.              +--------------------------------+
  852.              |         BIOS and DOS           |
  853.              +--------------------------------+ 0K
  854.  
  855.         Notice how, with Sidekick where it is, the Transient Program 
  856.         Area could not grow in size.  There is now a 32K hole of 
  857.         unusable memory just below Sidekick.  The correct 
  858.         AUTOEXEC.BAT
  859.  
  860.              sk
  861.              copy adjram.exe c:
  862.              c:adjram c: +64
  863.  
  864.         would produce the following memory layout after booting:
  865.  
  866.              +--------------------------------+ 640K
  867.              |                                |
  868.              |   Transient Program Area       |
  869.              |                                |
  870.              +--------------------------------+
  871.              |   Block #2 of RAM Disk (32K)   |
  872.              +--------------------------------+
  873.              |   Block #1 of RAM Disk (32K)   |
  874.              +--------------------------------+
  875.              |           Sidekick             |
  876.              +--------------------------------+
  877.              |           ANSI.SYS             |
  878.              +--------------------------------+
  879.              |   Block #0 of RAM disk (64K)   |
  880.              |                                |
  881.              +--------------------------------+
  882.              |          AMDISK.DVD            |
  883.              +--------------------------------+
  884.              |         BIOS and DOS           |
  885.              +--------------------------------+ 0K
  886.  
  887.         Now, if the RAM disk is shrunk (up to 64K, i.e., blocks #2 and 
  888.         #1), then the Transient Program Area will grow by that amount.  
  889.  
  890.         You generally shrink the RAM disk because you want to make more 
  891.         memory available for other programs.  But it defeats this 
  892.         objective to load memory resident programs after expanding the 
  893.         RAM disk.  So...
  894.  
  895.              First load the memory resident programs, then use ADJRAM to 
  896.              expand your RAM disk.  
  897.  
  898.         The Adjustable RAM disk doesn't "steal" interrupts from the 
  899.         system, so expanding the RAM disk after loading programs that 
  900.         intercept interrupts, such as Sidekick, SHOULDN't cause any 
  901.         problems.
  902.  
  903.         If you encounter compatibility problems, please let me know at 
  904.         the address I'll give at the end of this document.  I'd like to 
  905.         know about them so I can fix them if possible.  Please be as 
  906.         complete as possible when you explain the problem.  What memory 
  907.         resident programs did you have loaded and in what order?  How 
  908.         much memory do you have in your computer?  What computer and 
  909.         operating system were you running?  Exactly what happened when 
  910.         it didn't work?  I won't guarantee that I can fix the problem, 
  911.         but I'll try.  
  912.         
  913.                  
  914.         Known Compatibility Problems
  915.         ----------------------------
  916.         When using ADJRAM with DoubleDOS, new memory blocks are created 
  917.         within whichever partition is active at the time you run ADJRAM.  
  918.         If you attempt to shrink the RAM disk to gain additional room in 
  919.         the first partition, you may find that you didn't gain any room 
  920.         in the first partition!  Instead, the room gained was in the 
  921.         second partition (because that's where the memory blocks were 
  922.         created).  
  923.  
  924.         Also, DoubleDOS doesn't know about ADJRAM creating new memory 
  925.         blocks.  This causes DoubleDOS to tell you there is more room in 
  926.         partitions than actually exists.  Use CHKDSK to find out how big 
  927.         your partitions really are.  In general, you should try to run 
  928.         ADJRAM before activating DoubleDOS, to avoid this problem.
  929.  
  930.         ADJRAM is somewhat incompatible with MARK/RELEASE.  You can't 
  931.         expand the RAM disk after you've run MARK, because when you run 
  932.         RELEASE, AMDISK won't know that some of its memory blocks have 
  933.         been freed.  As long as you expand before you run MARK for the 
  934.         first time, you should be OK.  I have not tried MARK/RELEASE in 
  935.         conjunction with ADJRAM, so there may be other problems as well.  
  936.         The Referee, being a program similar to MARK/RELEASE, will 
  937.         problably also have these problems.  
  938.                  
  939.         One user reported that Sidekick version 1.11c locked up when 
  940.         used in conjunction with ADJRAM on his clone PC running MS-DOS 
  941.         3.2.  The same version of Sidekick checked out OK on a Sperry 
  942.         running MS-DOS 3.1.  I don't have easy access to a PC running 
  943.         3.2, so if anyone can help me resolve this problem, it would be 
  944.         appreciated.  
  945.  
  946.         Other Known Problems
  947.         --------------------
  948.         Some programs, such as PC-WRITE have a "shell" or "hotkey" 
  949.         command that allows you to suspend the program, keeping it in 
  950.         memory, and execute other DOS commands.  You may be tempted to 
  951.         use this capability to increase or decrease the size of the RAM 
  952.         disk in the middle of running another program.  But be careful 
  953.         here.  Consider the following sequence of events:
  954.  
  955.              1.  You're running (the fictitious) program RAZZLDOC, 
  956.                  editing file C:MYFILE.DOC on the RAM disk.  
  957.  
  958.              2.  You use RAZZLDOC's "shell" command to get the DOS 
  959.                  prompt.  
  960.         
  961.              3.  You use ADJRAM to expand the size of disk C, the RAM 
  962.                  disk.  
  963.  
  964.              4.  You use the DOS EXIT command to go back into RAZZLDOC.
  965.  
  966.              5.  Upon exiting RAZZLDOC, you're horrified to learn that 
  967.                  it was unable to successfully save all your work in 
  968.                  C:MYFILE.DOC.
  969.  
  970.         The problem here is that ADJRAM told DOS that the "media has 
  971.         changed" on disk C.  But RAZZLDOC had a file open on disk C!  
  972.         DOS can't properly close the file.  This sort of problem will 
  973.         generally occur with any program that has a "shell" command but 
  974.         fails to close all open files before executing the shell.  [One 
  975.         user reported to me that PC-WRITE does close its files before 
  976.         executing the shell, so it should be safe to run ADJRAM from PC-
  977.         WRITE.]
  978.  
  979.         This kind of problem can also occur with certain memory resident 
  980.         programs that, in effect, give you a "shell" command from within 
  981.         any program.  POPDOS is one such program.
  982.  
  983.         Remember that whenever you expand or shrink the RAM disk, you 
  984.         have, conceptually, removed the current "floppy disk" in the RAM 
  985.         drive, and replaced it with another "floppy disk" that just 
  986.         happens to have the same files as the one removed.  You wouldn't 
  987.         change a real floppy disk in the middle of editing a Wordstar 
  988.         file, so don't expand or shrink the RAM disk either.  
  989.  
  990.         I haven't actually tried it, but ADJRAM is likely to have 
  991.         problems under windowing systems, like Microsoft Windows, as 
  992.         well.  Users who try it, please let me know how it turned out.
  993.  
  994.  
  995.         Future Versions of DOS
  996.         ----------------------
  997.         It is unlikely that ADJRAM will be compatible with future 
  998.         versions of MS-DOS.  Starting with version 5, Microsoft plans on 
  999.         adding multi-tasking capability.  That will require much more 
  1000.         stringent memory management.  That management is likely to 
  1001.         conflict with the way ADJRAM works.  People running version 5 
  1002.         and above are likely to own hard disks and "virtual memory" 
  1003.         machines anyway, and the need for an adjustable RAM disk will 
  1004.         disappear.
  1005.  
  1006.  
  1007.         History
  1008.         -------
  1009.         3.0   This was the first version of ADJRAM to be released.  It
  1010.               was released to the public in September 1986.
  1011.         3.1   This version fixed a bug.  3.0 did not properly pack files
  1012.               in subdirectories under certain conditions.  This lead to
  1013.               a "bad file allocation table" error.  Release October 1986.
  1014.         3.2   This version added support for the SIZE= clause in 
  1015.               CONFIG.SYS.  Not publicly released.
  1016.         4.0   This version included the following bug fixes and 
  1017.               enhancements:
  1018.                 *  Full support for Expanded Memory
  1019.                 *  Support for Reserved Memory
  1020.                 *  Improved error reporting
  1021.                 *  /T option to display Memory Block Table
  1022.                 *  Max expansion and shrinkage automatically calculated.  
  1023.                    Users's request automatically rounded.
  1024.                 *  "Non IBM format" message from CHKDSK fixed by making
  1025.                    FAT ID masquerade as "double-sided 9-sector".
  1026.                 *  "Bad FAT" message when disk full bug fixed.
  1027.                 *  CLUSTER clause added to AMDISK.DVD
  1028.                 *  Volume label added to AMDISK.DVD
  1029.               Not publicly released
  1030.          4.1  This version added the following enhancements:
  1031.                 * Verify that reserved memory is segment a000 or above
  1032.                 * Initialize reserved memory to zeroes.
  1033.               Version 3.x and 4.x can not be mixed.
  1034.  
  1035.  
  1036.         Internals
  1037.         ---------
  1038.         This section is for anyone interested in the internal workings 
  1039.         of the Adjustable RAM Disk.  It is not necessary to know this 
  1040.         information to use the Adjustable RAM Disk, but it may be 
  1041.         helpful for resolving compatibility problems.  This section is 
  1042.         for advanced DOS programmers only.  
  1043.  
  1044.         AMDISK.DVD is a loadable device driver, just like VDISK or 
  1045.         ANSI.SYS.  By itself, it is a complete 64K RAM disk (assuming no 
  1046.         "MINSIZE=" clause is given in CONFIG.SYS).  A 64K "memory block" 
  1047.         is allocated immediately after the AMDISK code.  A Memory Block 
  1048.         Table is maintained in logical sector 0 (the boot sector) of the 
  1049.         RAM disk beginning at offset 1EH.  For each memory block, this 
  1050.         table contains a seven byte entry as follows: 
  1051.  
  1052.              1.  A byte indicating the type of memory block.  0 means 
  1053.                  the block is allocated in normal DOS memory.  1 means 
  1054.                  the block is allocated in Expanded Memory.  2 means the 
  1055.                  block is allocated in Reserved Memory.
  1056.         
  1057.              2.  A word giving the starting paragraph number of the 
  1058.                  memory block.  A paragraph of memory is simply 16 
  1059.                  bytes, so this number is just the absolute memory 
  1060.                  address shifted right by 4 bits.  All memory blocks 
  1061.                  begin on an even paragraph boundary.  This word is zero 
  1062.                  if there are no more memory blocks.  It is meaningless 
  1063.                  for Expanded Memory blocks.
  1064.  
  1065.              3.  A word giving the size of the memory block in 512-byte 
  1066.                  sectors.
  1067.  
  1068.              4.  A word giving the Expanded Memory handle for the memory 
  1069.                  block.  Zero for normal memory blocks.
  1070.  
  1071.         Immediately after booting, there is exactly one 64K (128 sector) 
  1072.         memory block in the Memory Block Table.  If a "MINSIZE=" clause 
  1073.         was given in CONFIG.SYS, the size will vary from 64K.  
  1074.  
  1075.         Note:  Don't confuse the memory blocks defined here with those 
  1076.                defined for DOS functions 48H thru 4AH.  To avoid 
  1077.                confusion -- and though not strictly accurate -- I'll 
  1078.                refer to DOS's memory blocks as "program segments".  
  1079.         
  1080.         The number of memory blocks allocated is stored in the media 
  1081.         descriptor byte at offset 15H of the boot sector.  Any time DOS 
  1082.         requests a media code from the AMDISK device driver, it returns 
  1083.         the number of memory blocks allocated.  In this way, any time 
  1084.         that the RAM Disk has been shrunk or expanded, DOS will know 
  1085.         that the "media has changed" and will rebuild its internal Disk 
  1086.         Parameter Block (DPB) tables.  This lets DOS know what the new 
  1087.         size of the RAM disk is.  
  1088.  
  1089.         The drive letter AMDISK.DVD uses is assigned by DOS.  AMDISK.DVD 
  1090.         gets the letter from DOS via function 19H (Get default disk 
  1091.         drive).  
  1092.         
  1093.         Upon startup of the ADJRAM program, it moves its own stack down 
  1094.         so that the program's total run size is less than 32K.  This 
  1095.         prevents corruption of future DOS memory arena blocks
  1096.  
  1097.         Also, DOS function 49H (release memory) is used to deallocate 
  1098.         its own environment segment.  This doesn't seem to hurt a 
  1099.         running program, and it is necessary to insure that this memory 
  1100.         can be used later when the RAM disk is shrunk.  
  1101.  
  1102.         At startup, the Expanded Memory version of ADJRAM tests whether 
  1103.         the Expanded Memory Manager (EMM) is loaded by opening device 
  1104.         "EMMXXXX0".  If the open fails, the EMM is not loaded.  If the 
  1105.         open succeeds, then the output status is requested from the 
  1106.         device using DOS function 44H (IOCTL).  If IOCTL reports a 
  1107.         status of 0, then coincidentally a file named "EMMXXXX0" existed 
  1108.         on the default disk, and the EMM is still not available.  If the 
  1109.         EMM is not available, ADJRAM reports an error and exits.
  1110.  
  1111.         Also upon startup, ADJRAM checks that the specified drive letter 
  1112.         corresponds to the AMDISK device.  The boot sector of the RAM 
  1113.         disk contains the string "AMDISK" at offset 03H.  The boot 
  1114.         sector is read using DOS interrupt 25H (absolute disk read).
  1115.  
  1116.         If the user has requested expansion of the RAM disk using 
  1117.         conventional memory, the program counts the number of available 
  1118.         32K memory blocks by allocating them using DOS function 48H 
  1119.         (allocate memory).  When it gets an error, it knows there are no 
  1120.         more available.  It then deallocates the blocks using DOS 
  1121.         function 49H (deallocate memory).  ADJRAM always leaves at least 
  1122.         one 32K block of free memory.  This is so that ADJRAM can be run 
  1123.         one more time in order to shrink the RAM disk.  
  1124.  
  1125.         If the user has requested shrinkage of the RAM disk, ADJRAM 
  1126.         examines the Memory Block Table to find out where the next 
  1127.         smaller size is.  It also uses the table to round the requested 
  1128.         shrink down to the nearest memory block boundary.
  1129.  
  1130.         When the ADJRAM program increases the size of the RAM disk, it 
  1131.         does so by allocating additional 32K (64 sector) memory blocks.  
  1132.         Normal memory blocks are allocated in two ways:
  1133.  
  1134.              1.  If it is the first memory block to be created (in this 
  1135.                  run of ADJRAM), then the memory block is allocated 
  1136.                  using DOS function 4AH (modify memory allocation).  
  1137.                  ADJRAM's own program segment is the one modified.  
  1138.                  Hence, the first memory block overwrites the ADJRAM 
  1139.                  program itself.
  1140.  
  1141.              2.  Additional memory blocks are allocated using DOS 
  1142.                  function 48H (allocate memory).  
  1143.  
  1144.         In either case, an appropriate entry is made in the Memory Block 
  1145.         Table, which is in the boot sector, for each new memory block.  
  1146.         At the end of the program, the boot sector is written back out 
  1147.         using DOS interrupt 26H (absolute disk write).  
  1148.         
  1149.         When ADJRAM exits normally, it uses DOS function 31H (terminate 
  1150.         and stay resident) to permanently allocate the new memory 
  1151.         blocks.  
  1152.         
  1153.         Expanded Memory blocks are allocated via EMM function 43H (Get 
  1154.         handle and allocate memory).
  1155.                  
  1156.         Reserved Memory blocks are not "allocated" at all.  ADJRAM 
  1157.         simply enters the starting paragraph and size into the Memory 
  1158.         Block Table.  It then zeroes the reserved memory.  That is why 
  1159.         this option is so dangerous.  
  1160.  
  1161.         When ADJRAM shrinks the RAM disk, it does these steps:
  1162.                  
  1163.              1.  It checks to insure there is sufficient free space in 
  1164.                  the RAM disk to do the shrink.  
  1165.              2.  The File Allocation Table (FAT) is read using DOS 
  1166.                  interrupt 25H.  The first available cluster number is 
  1167.                  determined.  
  1168.              3.  The first sector of the directory is read in using DOS 
  1169.                  interrupt 25H.
  1170.              4.  For each file, any clusters located after the first 
  1171.                  available cluster are moved down to the first available 
  1172.                  cluster.  Then the next available cluster is 
  1173.                  determined.  Clusters are moved in the RAM disk using
  1174.                  DOS interrupts 25H and 26H.  As clusters are moved, the
  1175.                  directory and FAT in memory are updated.  After all the
  1176.                  clusters of the file are packed down, and if the file
  1177.                  is a subdirectory, then the clusters of the directory
  1178.                  are read in and the file packing algorithm (steps 3 and
  1179.                  4) is recursively applied to each directory entry in
  1180.                  the file.
  1181.              5.  Step 4 is repeated for each additional directory 
  1182.                  sector.  Updated directory sectors are written back to 
  1183.                  the disk using DOS interrupt 26H.
  1184.              6.  The necessary number of memory blocks are deallocated, 
  1185.                  either using DOS function 49H (release memory) or EMM 
  1186.                  function 45H (release handle and memory).  The Memory 
  1187.                  Block Table is updated accordingly.  Blocks are 
  1188.                  deallocated in reverse of the order inwhich they are 
  1189.                  created.  
  1190.              7.  The updated FAT and boot sector are written back to the 
  1191.                  disk using DOS interrupt 26H.  
  1192.              8.  ADJRAM exits normally via DOS function 4CH (exit with 
  1193.                  return code).
  1194.  
  1195.         An excellent book for understanding DOS memory allocation and 
  1196.         disk structure is the "MsDOS Developer's Guide", written by the 
  1197.         Waite Group and published by SAMS.  Another excellent book, 
  1198.         which includes documentation on Expanded Memory, is "Advanced 
  1199.         MS-DOS" by Ray Duncan.
  1200.         
  1201.         In the course of developing this program, I discovered a couple 
  1202.         of interesting things about the DOS version 2 memory allocation 
  1203.         functions (48H thru 4AH).  
  1204.  
  1205.              1.  Transient programs are always loaded after the last 
  1206.                  allocated memory block, even if there is sufficient 
  1207.                  memory available in "holes" below the last allocated 
  1208.                  memory block.  Such holes could be created by loading a 
  1209.                  memory resident program, such as Sidekick, and then 
  1210.                  shrinking the RAM disk.
  1211.  
  1212.              2.  The allocate memory function (48H), on the otherhand, 
  1213.                  will use holes if they exist and if they are large 
  1214.                  enough to contain the requested block.
  1215.  
  1216.              3.  If a program modifies a DOS memory block (function 
  1217.                  4AH), it becomes the "owner" of that block, even if it 
  1218.                  didn't create the block in the first place.  When such 
  1219.                  a program exits, the block will be automatically 
  1220.                  deallocated by DOS unless the program exits via 
  1221.                  terminate and stay resident.   This is why ADJRAM must 
  1222.                  allocate memory blocks in fixed 32K increments.  
  1223.                  Ideally, it should allocate exactly the requested size 
  1224.                  and no more.  The DOS quirk described here prevents 
  1225.                  that though.
  1226.  
  1227.         The source code for the Adjustable RAM Disk is included with the 
  1228.         program.  AMDISK.DVD is coded in MASM version 1.27; ADJRAM.EXE 
  1229.         is coded in DeSmet C version 2.4.  Even though I've included the 
  1230.         source code, I would nevertheless like to act as the 
  1231.         clearinghouse for all future versions and modifications.  If you 
  1232.         make a change to the program, or fix a bug, PLEASE let me know 
  1233.         about it -- I may want to include the change in future versions.  
  1234.         
  1235.         If you modify the program, you agree to maintain my copyright.  
  1236.         You should indicate that you've modified the program by changing 
  1237.         the version number, for example "version 4.1A", or by putting 
  1238.         some other distinguishing message in the signon of the program, 
  1239.         for example "custom version by John Doe".  The rational for this 
  1240.         is simple -- I don't won't to be blamed for your bug.  
  1241.  
  1242.         My address, as of May 1988 is:
  1243.  
  1244.              GARY CRAMBLITT
  1245.              105 TENNESSEE RD
  1246.              STEVENSVILLE, MD  21666
  1247.  
  1248.         Please do not telephone.  I'd like to receive your letter.  
  1249.         Please note that my address is given above in order to support 
  1250.         users who encounter difficulty running ADJRAM.  I can not afford 
  1251.         to distribute copies of ADJRAM so please do not publish this 
  1252.         address.  I rely upon RBBSs and user groups to distribute 
  1253.         ADJRAM.  
  1254.  
  1255.                        * * * *  END OF ADJRAM.DOC * * * *
  1256.  
  1257.